package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.ScadaBasePoint;

public interface ScadaBasePointRepository extends JpaRepository<ScadaBasePoint, String>{

	@Query(" select s from ScadaBasePoint s where s.scadaRtuBaseInfoId = ?1 and (s.name like '%'+?2+'%' or s.alias like '%'+?2+'%' "
			+ "or s.memo like '%'+?2+'%' or s.dataField like '%'+?2+'%' ) ")
	Page<ScadaBasePoint> getScadaBasePointsbyScadaRtuBaseInfoId(String scadaRtuBaseInfoId, String key, Pageable pageable);

	@Query(" select count(*) from ScadaBasePoint s where s.scadaRtuBaseInfoId = ?1 and (s.name like '%'+?2+'%' or s.alias like '%'+?2+'%' "
			+ "or s.memo like '%'+?2+'%' or s.dataField like '%'+?2+'%' ) ")
	long getScadaBasePointsbyScadaRtuBaseInfoIdCount(String string, String string2);

	@Query(" select s from ScadaBasePoint s where s.id in (?1)  ")
	List<ScadaBasePoint> findbyPointids(String ids);
	
	@Query(" select s from ScadaBasePoint s where s.scadaRtuBaseInfoId in (?1)")
	List<ScadaBasePoint> getScadaBasePointsbyScadaRtuBaseInfoIds(String scadaRtuBaseInfoIds);

}
